package com.springboot.casclient2.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: TongRui乀
 * @Date: 2020-03-25 13:50
 * @description：
 */
@Controller
public class IndexController {

    @GetMapping("index")
    public String index(){
        return "index";
    }


    @GetMapping("hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("logout")
    public String logout(HttpSession session){
        // 清除本地session
        session.invalidate();

        String logutUrl = "http://cas.server.com:8443/cas/logout?service=http://cas.client1.com:8001/logout/success";

        return "redirect:" + logutUrl;
    }


    @GetMapping("logout/success")
    @ResponseBody
    public Map<String,String> logoutSuccess(){

        HashMap<String, String> map = new HashMap<String, String>();

        map.put("code", "1000");
        map.put("message", "退出登录成功");

        return map;
    }

}
